import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../common/ObjCreate";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { Language } from "../../../../extend/language/Language";
import { ImagesConst } from "../../resource/ImagesConst";
import { BaseItemNormal } from "../common/item/BaseItemNormal";
import { FabaoItem } from "../player/fabao/FabaoItem";
import { MagicWeaponCellInfo } from "./MagicWeaponCellInfo";
import { EntityUtil } from "../../scene/layer/utils/EntityUtil";
import { Cache } from "../../cache/Cache";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
type int = number;
//class MagicWeaponCellRender
    
    export  class MagicWeaponCellRender extends GCellRenderer
    {
        constructor()
        {
            super();
            this.contentBox = new Object /* flash.display.Sprite */();
            this.addChild(this.contentBox);
            return;
        }

        protected /* override */ configUI(): void
        {
            super.configUI();
            this._cellBg = ObjCreate.createBg(0, 0, 249, 99, this);
            var loc1=new GTextFormat(FontUtil.xingkaiName, 17, GlobalStyle.color6Uint);
            ObjCreate.createTextField(Language.getString(85085), 103, 8, 60, 26, this.contentBox, loc1, false, false);
            ObjCreate.createTextField(Language.getString(85086), 173, 8, 60, 26, this.contentBox, loc1, false, false);
            var loc2=new GTextFormat(FontUtil.EmbedNumberName, 17, GlobalStyle.color6Uint);
            this._scoreTextfield = ObjCreate.createEmbedTextFiled("", 147, 8, 40, 26, this.contentBox, loc2);
            this._rankTextfield = ObjCreate.createEmbedTextFiled("", 217, 8, 40, 26, this.contentBox, loc2);
            var loc3=GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat1);
            this._magicWeaponNameTxt = ObjCreate.createTextField("", 142, 30, 110, 26, this.contentBox, loc3, true, false);
            this._ownerNameTxt = ObjCreate.createTextField("", 142, 50, 110, 26, this.contentBox, loc3, true, false);
            this._ownerServerTxt = ObjCreate.createTextField("", 142, 70, 110, 26, this.contentBox, loc3, true, false);
            ObjCreate.createBitmap(ImagesConst.MagicWeaponItemBg, 10, 5, this.contentBox);
            this._fabaoItem = this.createFabaoItem(40, 34, true, 19);
            this._baseItem = new BaseItemNormal();
            this._baseItem.setSize(32, 32);
            this._baseItem.isDragAble = false;
            this._baseItem.isDropAble = false;
            ObjCreate.setObjAttri(this._baseItem, 113, 41, -1, -1, this.contentBox);
            return;
        }

        /* internal  */createFabaoItem(arg1: number, arg2: number, arg3: Boolean, arg4: int): FabaoItem
        {
            var loc1=null;
            (loc1 = new FabaoItem()).x = arg1;
            loc1.y = arg2;
            loc1.isOpen = arg3;
            loc1.posIndex = arg4;
            this.contentBox.addChild(loc1);
            return loc1;
        }

        /* internal  */createBitmap(arg1: int, arg2: int): Object /* flash.display.Bitmap */
        {
            var loc1=null;
            loc1 = new Object /* flash.display.Bitmap */();
            loc1.x = arg1;
            loc1.y = arg2;
            addChild(loc1);
            return loc1;
        }

        public /* override */ set data(arg1: Object)
        {
            this._info = arg1 as MagicWeaponCellInfo;
            if (this._info) 
            {
                this._scoreTextfield.text = String(this._info.score);
                this._rankTextfield.text = String(this._info.rank);
                this._magicWeaponNameTxt.htmlText = this._info.magicWeaponName;
                this._ownerServerTxt.htmlText = EntityUtil.getProxyNameByProxyAndServer(this._info.proxyId, this._info.serverId) + Language.getString(36178);
                this._ownerNameTxt.htmlText = this._info.ownerName;
                this._fabaoItem.itemData = this._info.itemdata;
                this._fabaoItem.posIndex = this._info.itemdata.data.posType;
                this._baseItem.itemData = Cache.instance.magicWeaponRankingCache.getRewardItem(this._info.isCross, this._info.rank);
                this._baseItem.visible = this._baseItem.itemData ? true : false;
                this.visible = true;
            }
            else 
            {
                this._fabaoItem.itemData = null;
                this._baseItem.itemData = null;
                this.visible = false;
            }
            return;
        }

        /* internal */ /* var */_info: MagicWeaponCellInfo;

        protected /* var */_cellBg: ScaleBitmap;

        /* internal */ /* var */_baseItem: BaseItemNormal;

        /* internal */ /* var */_rankTextfield: Object /* flash.text.TextField */;

        /* internal */ /* var */_scoreTextfield: Object /* flash.text.TextField */;

        /* internal */ /* var */_magicWeaponNameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_ownerServerTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_ownerNameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_fabaoItem: FabaoItem;

        protected /* var */contentBox: Object /* flash.display.Sprite */;
    }
